﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using JXT.PrimaryKey.Batman.Domain.Models;

namespace JXT.PrimaryKey.Batman.Domain.Specifications.Expressions
{
    public class OrderedExpressionSpecification<TEntity> : 
        ExpressionSpecification<TEntity>, IOrderedSpecification<TEntity> 
        where TEntity : IEntity
    {
        private readonly Queue<Tuple<Expression, OrderType>> _orderExpressionQueue = new Queue<Tuple<Expression, OrderType>>();

        public Queue<Tuple<Expression, OrderType>> OrderExpressionQueue { get { return _orderExpressionQueue; } }

        public void OrderBy<TProperty>(Expression<Func<TEntity, TProperty>> orderExpression, OrderType type = OrderType.Ascending)
        {
            _orderExpressionQueue.Enqueue(Tuple.Create<Expression, OrderType>(orderExpression, type));
        }
    }
}
